package com.bw.broker.controller;


import com.bw.broker.service.TbHouseBrokerLiveService;
import com.bw.result.ResultVo;
import com.bw.vo.TbHouseLiveVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: FanYangJie
 * @BelongsProject: search-house
 * @BelongsPackage: com.bw.live.controller
 * @Date: 2023/11/12 21:45
 * @Description: TODO
 */
@RestController
@Slf4j
@RequestMapping("/live")
@Api(tags = "直播后台管理")
public class TbHouseLiveController {
    @Autowired
    private TbHouseBrokerLiveService tbHouseBrokerLiveService;

    /**
     * @deprecated: TODD 获取直播列表(经纪人姓名模糊查询,经纪人id查询,直播状态查询)
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/12 21:47
     */
    @PostMapping("/liveList")
    @ApiOperation(value = "直播列表")
    public ResultVo liveList(@RequestBody TbHouseLiveVo tbHouseLiveVo){
        return tbHouseBrokerLiveService.liveList(tbHouseLiveVo);
    }

    /**
     * @deprecated: TODD 查看直播间详情
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/13 9:43
     */
    @PostMapping("/getLive")
    @ApiOperation(value = "直播详情")
    public  ResultVo getLive(@RequestBody TbHouseLiveVo tbHouseLiveVo){
        return  tbHouseBrokerLiveService.getLive(tbHouseLiveVo);
    }

    /**
     * @deprecated: TODD 添加直播间
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/13 9:53
     */
    @PostMapping("/add")
    @ApiOperation(value = "直播添加")
    public ResultVo add(@RequestBody TbHouseLiveVo tbHouseLiveVo){
        return  tbHouseBrokerLiveService.add(tbHouseLiveVo);
    }

    /**
     * @deprecated: TODD 删除直播间
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/13 11:16
     */
    @PostMapping("/deleteLive")
    @ApiOperation(value = "删除直播间")
    public  ResultVo deleteLive(@RequestBody TbHouseLiveVo tbHouseLiveVo){
        return tbHouseBrokerLiveService.deleteLive(tbHouseLiveVo);
    }

    /**
     * @deprecated: TODD 修改直播信息
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/13 11:48
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改直播信息")
    public  ResultVo update(@RequestBody TbHouseLiveVo tbHouseLiveVo){
        return  tbHouseBrokerLiveService.updateLive(tbHouseLiveVo);
    }

    /**
     * @deprecated: TODD 打开直播录制
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/15 16:00
     */
    @PostMapping("/openCloudRecording")
    @ApiOperation(value = "打开直播录制")
    public  ResultVo openCloudRecording(@RequestBody TbHouseLiveVo tbHouseLiveVo){
        return  tbHouseBrokerLiveService.openCloudRecording(tbHouseLiveVo);
    }

    /**
     * @deprecated: TODD 关闭直播
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/15 16:05
     */
    @PostMapping("/closeDeleteCloudRecording")
    @ApiOperation(value = "关闭直播")
    public  ResultVo closeDeleteCloudRecording(@RequestBody String taskId){
        return  tbHouseBrokerLiveService.closeDeleteCloudRecording(taskId);
    }

    /**
     * @deprecated: TODD 音视频录制回调接口 当云端录制回调监听到录制上传成功事件，
     * 就会调用下载音视频接口，我们根据我们给我们数据库存储地址的表中标记，未下载的
     * 进行下载。为了保证数据的安全性，我们需要把云点播的音视频存储到医院的服务器上面，
     * 然后将云点播上面的音视频删除掉，然后将存储地址表中的视频路径改成服务器的路径。
     * @Author: FAnYangJie〔^.べ〕γ
     * key：控制台配置的密钥key
     * body：腾讯云回调返回的body体
     * sign：腾讯云回调返回的签名值sign
     * @Date: 2023/11/15 20:52
     */
    @ApiOperation(value = "云端音视频录制回调接口")
    @PostMapping("/recordingCallback")
    public  ResultVo recordingCallback(@RequestBody String body, HttpServletRequest request) throws Exception {
        return  tbHouseBrokerLiveService.recordingCallback(body, request);
    }

    /**
     * @deprecated: TODD 腾讯云上点播
     * @Author: FAnYangJie〔^.べ〕γ
     * @Date: 2023/11/15 22:06
     */
    @PostMapping("/recordingCall")
    @ApiOperation(value = "腾讯云点播")
    public  ResultVo recordingCall(@RequestBody String body,HttpServletRequest request) throws Exception {
        return  tbHouseBrokerLiveService.recordingCall(body, request);
    }



}
